﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication.MyPassword
{
    public partial class Password : Form
    {
        /*
         *  PROCEDURE Update IS
            BEGIN

            rtbUserName.Enabled=False;
            rtbPassword.Enabled=False;
            rtbURL.Enabled=False;
            rtbOther.Enabled=False;

            there four controls databindings to same bindingsource as DataTable

            When add New or delete one, rebinding itself.

            END
 
         */
        public Password()
        {
            InitializeComponent();
        }

        private void MyPassword_Load(object sender, EventArgs e)
        {
            disableElements();
        }

        private void Event_Method(object sender, EventArgs e)
        {
            
        }

        private void disableElements()
        {
            //this.Enabled = false;

            rgvSearch.Enabled = false;
            radGroupBox1.Enabled = false;
            rbtSearch.Enabled = false;
            rbtNewButton.Enabled = false;
        }

        private void enableElements()
        {
            //this.Enabled = false;

            rgvSearch.Enabled = true;
            radGroupBox1.Enabled = true;
            rbtSearch.Enabled = true;
            rbtNewButton.Enabled = true;
        }

        private void Event_Method(object sender, TEventArgs e)
        {
            // TODO: if password is ok, then call this funciton
            enableElements();
        }

        private void Password_Shown(object sender, EventArgs e)
        {
            Login login = new Login();
            login.eventArgs += Event_Method;
            login.ShowDialog();
        }

        private void rbtNewButton_Click(object sender, EventArgs e)
        {
            NewUserName newUserName = new NewUserName();
            newUserName.StartPosition = FormStartPosition.CenterParent;
            newUserName.eventHandler += new EventHandler(Event_Method);
            newUserName.ShowDialog();
        }

        private void rbtUpdate_Click(object sender, EventArgs e)
        {

        }
    }
}
